package com.liebaut.exception;

import com.google.common.collect.ImmutableMap;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.view.json.MappingJacksonJsonView;

/**
 * Created with IntelliJ IDEA.
 * User: User
 * Date: 22/02/14
 * Time: 11:19
 * To change this template use File | Settings | File Templates.
 */
public class JsonError {

    private final String message;

    public JsonError(String message) {
        this.message = message;
    }

    public ModelAndView asModelAndView() {
        MappingJacksonJsonView jsonView = new MappingJacksonJsonView();
        return new ModelAndView(jsonView, ImmutableMap.of("error", message));
    }
}
